package com.example.demo.controller;

import com.example.demo.config.People;
import com.example.demo.entity.User;
import com.example.demo.service.AopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/aopController")
@Validated
public class AopController {
    @Autowired
    private AopService aopService;

    @RequestMapping(value = "/sayHello", method = RequestMethod.GET)
    public String sayHello(HttpServletRequest request, HttpServletResponse response, int name, int age) {
        return aopService.sayHello(name);
    }

    @PostMapping("/user")
    public User user(HttpServletRequest request, HttpServletResponse response, @Validated @RequestBody User user) {
        return user;
    }

    @GetMapping("/user2")
    public String user() {
        return "user";
    }

    @PostMapping("/user3")
    public String user3() {
        return "user";
    }
}
